import axios from 'axios'

import NProgress from 'nprogress'

// 使用CDN引入
// import 'nprogress/nprogress.css'

const axiosIns = axios.create({
  baseURL: '/mock',
  timeout: 10000
})

axiosIns.interceptors.request.use(function (config) {
  NProgress.start()
  return config
})

axiosIns.interceptors.response.use(function (response) {
  NProgress.done()
  return response.data
}, function (error) {
  NProgress.done()
  return Promise.reject(error)
})

export default axiosIns
